package com.smartleanx.module.hrm.intergration;

import com.smartleanx.module.system.api.notify.NotifyMessageSendApi;
import com.smartleanx.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Component
public class NotifyMessageServiceProvider {

    @Resource
    private NotifyMessageSendApi notifyMessageSendApi;

    /**
     * 发送单条站内信给 指定 用户
     * @param userId 用户ID
     * @param templateCode 模板编码
     * @param options 业务相关页面请求参数
     * @param detailType 业务模块类型
     * @param templateParams 模板参数
     * @return 站内信ID
     */
    public Long sendSingleMessageToAdmin(Long userId, String templateCode, String options, Integer detailType, Map<String, Object> templateParams){
        return notifyMessageSendApi.sendSingleNotify(NotifySendSingleToUserReqDTO.builder().userId(userId)
                .templateCode(templateCode).options(options).detailType(detailType).templateParams(templateParams).build()).getCheckedData();
    }

    public Long sendSingleNotify(NotifySendSingleToUserReqDTO reqDTO){
        return notifyMessageSendApi.sendSingleNotify(reqDTO).getCheckedData();
    }

    public void sendSingleNotifyBatch(List<NotifySendSingleToUserReqDTO> reqDTOS){
        notifyMessageSendApi.sendSingleNotifyBatch(reqDTOS).getCheckedData();
    }

}
